import { CopyBitmapWindows } from "./CopyBitmapWindows";
import { LayerManager } from "../../manager/LayerManager";
import { TweenLite } from "../../../../com/greensock/TweenLite";
import { TweenMax } from "../../../../com/greensock/TweenMax";
import { 26 } from "../../../../0/26";
//class TweenMainUI
    
    export  class TweenMainUI
    {
        

        public setCloseType(arg1, arg2: Object /* flash.display.DisplayObject */): void
        {
            if (typeof arg1 === "string") 
            {
                this._closeType = arg1 as string;
            }
            else if (arg1 is flash.display.DisplayObject) 
            {
                this._closeType = "DisplayObject";
                this._closeTarget = arg1;
            }
            this._target = arg2;
            return;
        }

        public closeTween(): void
        {
            var loc2=null;
            var loc1=[];
            if (!(this._closeType == "") && !this._isTweening) 
            {
                if (this._closeType != "DisplayObject") 
                {
                    this._closePoint = CopyBitmapWindows.getBtnPoint(this._closeType);
                }
                else 
                {
                    this._closePoint = CopyBitmapWindows.getBtnPoint(this._closeTarget);
                }
                loc2 = new Object /* flash.display.BitmapData */(this._target.width - 20, this._target.height - 10, false, 0);
                loc2.draw(this._target, new Object /* flash.geom.Matrix */(1, 0, 0, 1, -10, -5), null, null, new Object /* flash.geom.Rectangle */(0, 0, this._target.width - 20, this._target.height - 10));
                if (!this._closeWin) 
                {
                    this._closeWin = new CopyBitmapWindows();
                }
                this._closeWin.bitmapData = loc2;
                this._closeWin.x = this._target.getBounds(LayerManager.topLayer).left + this._target.width / 2;
                this._closeWin.y = this._target.getBounds(LayerManager.topLayer).top + this._target.height / 2;
                LayerManager.topLayer.addChild(this._closeWin);
                this._closeWin.alpha = 1;
                this._isTweening = true;
                TweenLite.to(this._closeWin, 0.4, {"height": 20, "width": 20, "alpha": 26});
                TweenMax.to(this._closeWin, 0.5, {"x": this._closePoint.x, "y": this._closePoint.y, "onComplete": this.closeWinComplete});
            }
            return;
        }

        /* internal  */closeWinComplete(): void
        {
            this._isTweening = false;
            if (this._closeType != "") 
            {
                if (this._closeType != "DisplayObject") 
                {
                    this._closeTarget = CopyBitmapWindows.getBtn(this._closeType);
                }
            }
            this._closeWin.dispose();
            return;
        }

        public dispose(): void
        {
            if (this._closeWin) 
            {
                this._closeWin.dispose();
            }
            return;
        }

        /* internal */ /* var */_closeType: string="";

        /* internal */ /* var */_closePoint: Object /* flash.geom.Point */;

        /* internal */ /* var */_closeTarget: Object /* flash.display.DisplayObject */;

        /* internal */ /* var */_target: Object /* flash.display.DisplayObject */;

        protected /* var */_closeWin: CopyBitmapWindows;

        /* internal */ /* var */_isTweening: Boolean=false;
    }
